Component({
  data: {
    currentIndex: 0,
    categories: [
        { name: '全部', icon: '/images/category/bianmu.png', type: 'all' },
        { name: '狗', icon: '/images/category/bianmu.png', type: 'dog' },
        { name: '猫', icon: '/images/category/nainiumao.png', type: 'cat' },
        { name: '鸟', icon: '/images/category/Puffin Bird.png', type: 'bird' },
        { name: '其他', icon: '/images/category/gengduomengchong.png', type: 'others' }
      ]
  },
  methods: {
    onSelect(e) {
        const index = e.currentTarget.dataset.index;
        const selected = this.data.categories[index];
        this.setData({ currentIndex: index });
        this.triggerEvent('change', { index, type: selected.type });
    }
  }
});
